"""
URL configuration for student project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path

from StuApp.views import logInOut, userHub, gradeInfo, classinfo, stuInfo, index  # 添加 index 导入

urlpatterns = [
    # 登录相关
    path('', logInOut.stuLogin, name='login'),  # 设置登录页面为默认路由
    path('index/', index.index, name='index'),  # 使用新的 index 视图
    path('logout/', logInOut.logout, name='logout'),  # 注销登录
    path('layout/', index.layout, name='layout'),  # 布局页面

    # 管理员管理
    path('index/userhub/list', userHub.userHub, name='user_hub'),
    path('index/userhub/add', userHub.addAdmin, name='add_admin'),  # 添加管理员
    # path('index/userhub/search', userHub.searchAdmin, name='search_admin'),  # 搜索管理员
    path('index/userhub/reset/<str:admin_id>/', userHub.resetPassword, name='reset_password'),
    path('index/userhub/delete/<str:admin_id>/', userHub.deleteAdmin, name='delete_admin'),
    path('index/userhub/toggle_superuser/<str:admin_id>/', userHub.toggle_superuser, name='toggle_superuser'),

    # 年级管理
    path('index/grade/list', gradeInfo.gradeList, name='grade_list'),
    path('index/grade/update', gradeInfo.updateGradeYear, name='update_grade_year'),
    
    # 班级管理
    path('index/class/list', classinfo.classList, name='class_list'),
    path('index/class/add', classinfo.addClass, name='add_class'),
    path('index/class/update/<int:class_id>/', classinfo.updateClass, name='update_class'),
    path('index/class/delete/<int:class_id>/', classinfo.deleteClass, name='delete_class'),
    
    # 学生管理
    path('index/stu/list', stuInfo.stuList, name='stu_list'),
    path('index/stu/add', stuInfo.addStu, name='add_stu'),
    path('index/stu/delete/<str:stu_id>/', stuInfo.deleteStu, name='det_stu'),
    path('index/stu/update/<str:stu_id>/', stuInfo.updateStu, name='update_stu'),

    # 修改密码
    path('index/change_password/', logInOut.change_password, name='change_password'),
]
